-
Notifications
You must be signed in to change notification settings - Fork 5
Add implicit solvers for heat conduction equation #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #161 +/- ##
==========================================
+ Coverage 93.99% 94.02% +0.02%
==========================================
Files 11 12 +1
Lines 683 786 +103
==========================================
+ Hits 642 739 +97
- Misses 41 47 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d6c7d60
to
81e4777
Compare
Implement implicit Euler and Crank-Nicolson methods.
Use `x` for the solution vector in each solver as temperature at the next time step, instead of `T`.
- forward Euler -> implicit Euler - backward Euler -> explicit Euler
05b07c1
to
cd77191
Compare
Previously, boundary conditions were applied after solving the tridiagonal system, which resulted in incorrect temperature values. This commit fixes the implementation by properly incorporating boundary conditions into the matrix coefficients before solving. Changes: - Isothermal BC: Set matrix row to enforce T[i] = T_iso directly - Insulation BC: Use ghost point method to enforce ∂T/∂z = 0 - Radiation BC: Keep as post-processing due to nonlinearity - Apply same fix to both Implicit Euler and Crank-Nicolson methods Add comprehensive boundary condition tests: - Test isothermal BC with non-zero temperatures (T_upper=100, T_lower=50) - Test insulation BC at lower boundary - Verify that boundary conditions are correctly satisfied - Add tests to main test suite in runtests.jl This ensures that the implicit methods work correctly for all types of boundary conditions, not just the special case where T=0 at boundaries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces two new implicit solvers (Implicit Euler and Crank–Nicolson) for the 1D heat conduction equation, renames the existing forward/backward Euler types for clarity, and enhances boundary‐condition support and testing.
- Renamed
ForwardEulerSolver
→ExplicitEulerSolver
andBackwardEulerSolver
→ImplicitEulerSolver
. - Implemented proper incorporation of isothermal, insulation, and radiation boundary conditions into the implicit solvers’ tridiagonal systems.
- Added an analytical solution module plus new tests covering boundary conditions and solver accuracy.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/TPM.jl | Renamed solver types and removed duplicate broadcast call. |
src/heat_conduction.jl | Updated dispatch to use new solver names and fields. |
src/heat_conduction_analytical.jl | Added analytical solution function with documentation. |
test/heat_conduction_1D.jl | Updated tests for all three solvers and added error function. |
test/test_boundary_conditions.jl | New tests for isothermal and insulation boundary conditions. |
test/thermal_radiation.jl | Updated to use ExplicitEulerSolver . |
other test/TPM_*/*.jl files |
Replaced legacy ForwardEulerSolver with ExplicitEulerSolver . |
Comments suppressed due to low confidence (3)
test/heat_conduction_1D.jl:15
- Typo in the comment: change 'Seeting' to 'Setting' to improve readability.
##= Seeting of time step =##
src/TPM.jl:20
- [nitpick] Field name
x
is ambiguous; consider renaming it to something more descriptive (e.g.,T_next
ornext_temperature
) for clarity.
x::Vector{Float64} # Temperature vector for the next time step
test/test_boundary_conditions.jl:1
- Tests cover isothermal and insulation BCs, but there’s no coverage for
RadiationBoundaryCondition
in the heat‐conduction solvers—adding such a case would ensure full BC validation.
@testset "Boundary Conditions" begin
- Zero-conductivity case -> Calculate the radiative equilibrium temperature. - Non-zero conductivity case -> Call a numerical solution method to calculate the temperature.
- Replace the Unicode middle dot (・) with ASCII caret (^) in the docstring of `heat_conduction_analytical.jl` to fix the "invalid escape sequence" error in Julia 1.6. - This ensures compatibility with Julia 1.6 while maintaining the visual clarity of the ASCII art diagram.
…ction_analytical.jl`.
Summary
This PR adds support for multiple numerical solvers for the heat conduction equation. In addition to the existing explicit Euler method, implicit Euler and Crank-Nicolson methods are now available, providing better stability and accuracy options.
Changes
ForwardEulerSolver
→ExplicitEulerSolver
BackwardEulerSolver
→ImplicitEulerSolver
Usage
Breaking Changes
ForwardEulerSolver
→ExplicitEulerSolver
BackwardEulerSolver
→ImplicitEulerSolver
Tests
All tests pass, including new boundary condition tests. In future pull requests, add further tests for each solver and boundary condition.